/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package battleship_client.screens;

import battleship_client.Controller;
import java.awt.*;
import javax.swing.*;

/**
 *
 * @author jalejandrovc
 */
public class GameOrSettingsScreen extends Screen{

    public GameOrSettingsScreen(Controller wh){
        windowHandler = wh;
        setLookAndFeel();
        initComponents();
    }

    private void initComponents(){
        setTitle("Welcome to Battleships");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(400, 250);
        setResizable(false);
        setLocationRelativeTo(null);

        contentPane = getContentPane();
        mainPanel = new JPanel();
        btnChangeSettings = new JButton("Change data");
        btnPlayGame = new JButton("Play Game");
        btnViewStatistics = new JButton("My score");
        lblState = new JLabel("");
        lblImage = new JLabel();

        mainPanel.setLayout(null);
        lblImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/400x100.png")));
        lblImage.setBounds(0,0,400,100);
        btnPlayGame.setBounds(140, 110, 120, 30);
        btnPlayGame.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblState.setText("Waiting for server...");
                lblState.setVisible(true);
                windowHandler.playGame();
            }
        });
        btnChangeSettings.setBounds(140, 145, 120, 30);
        btnChangeSettings.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                windowHandler.getData();
            }
        });

        btnViewStatistics.setBounds(140, 180, 120, 30);
        btnViewStatistics.setVisible(true);
        btnViewStatistics.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                windowHandler.showScores();
            }
        });
        
        lblState.setVisible(false);
        lblState.setBounds(10, 160, 300, 15);

        mainPanel.add(lblImage);
        mainPanel.add(btnChangeSettings);
        mainPanel.add(btnPlayGame);
        mainPanel.add(btnViewStatistics);
        mainPanel.add(lblState);
        contentPane.add(mainPanel);
    }

    public void setLblState(String message){
        lblState.setText(message);
        lblState.setVisible(true);
    }

    private Controller windowHandler;
    private Container contentPane;
    private JPanel mainPanel;
    private JButton btnPlayGame;
    private JButton btnChangeSettings;
    private JButton btnViewStatistics;
    private JLabel lblImage;
    private JLabel lblState;
}
